﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework5
{
    class Order
    {
        private Customer customer;
        private int num;
        private OrderDetails details;

        public Order(Customer customer,  int num, OrderDetails details)
        {
            this.customer = customer;
            this.num = num;
            this.details = details;
        }

        public Customer Customer
        {
            get { return customer; }
            set { customer = value; }
        }
        public int Num
        {
            get { return num; }
            set { num = value; }
        }
        public OrderDetails Details
        {
            get { return details; }
            set { details = value; }
        }

        public override string ToString()
        {
            return $"订单号：{num}，"+customer.ToString()+ $"订单细节：{details}";
        }
        public override bool Equals(object obj)
        {
            Order o = obj as Order;
            return o != null && o.Details == details && o.Customer == customer ;
        }

        public override int GetHashCode()
        {
            var hashCode = -830296188;
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(customer.ToString());
            hashCode = hashCode * -1521134295 + num.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer<OrderDetails>.Default.GetHashCode(details);
            hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Customer.ToString());
            hashCode = hashCode * -1521134295 + Num.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer<OrderDetails>.Default.GetHashCode(Details);
            return hashCode;
        }
    }
}
